package com.atguigu.spzx.manager.mapper;

import com.atguigu.spzx.model.dto.system.ForgetPasswordDto;
import com.atguigu.spzx.model.dto.system.RegisterDto;
import com.atguigu.spzx.model.dto.system.SysUserDto;
import com.atguigu.spzx.model.entity.system.SysUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author ljl
 * @create 2023-10-22-16:37
 */
@Mapper
public interface SysUserMapper {

    /**
     * 根据用户名查询用户数据
     * @param userName
     * @return
     */
    public abstract SysUser selectByUserName(String userName) ;

    /**
     * @Description: 用户条件分页查询接口
     * @param sysUserDto
     */
    List<SysUser> findByPage(SysUserDto sysUserDto);

    void saveSysUser(SysUser sysUser);

    void updateSysUser(SysUser sysUser);

    void deleteById(Long userId);

    void updatePassword(ForgetPasswordDto forgetPasswordDto);

    void registerUser(RegisterDto registerDto);

    @Select("Select id from sys_user where id=#{id} and password=#{oldPassword}")
    Long compare(Long id, String oldPassword);

    @Update("update sys_user set password=#{newPassword} where id=#{id}")
    void AlterPassword(Long id, String newPassword);

    @Update("update sys_user set username=#{userName}, " +
            "name=#{name}, phone=#{phone}, avatar=#{avatar}, QRcode=#{QRcode} where id=#{id}")
    void AlterUserinfo(SysUser sysUser);
}